<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		p {
			margin: 0;
		}
		#lineBar {
			position: absolute;
			top: 100px; left: 100px;
			background: #ccc;
			width: 20px;
			height: 500px;
		}
		#bar {
			width: 20px;
			height: 20px;
			position: absolute;
			top: 0; left: 0;
			background: #58a;
		}
		#text {
			position: absolute;
			top: 100px; left: 150px;
			width: 300px;
			height: 0px;
			border: 1px solid black;
			background: #58a;
		}
	</style>
</head>
<body>
	<div id="lineBar">
		<div id="bar"></div>
	</div>
	<div id="text"></div>
	<script>
		var lineBar = document.getElementById('lineBar');
		var bar = document.getElementById('bar');
		var text = document.getElementById('text');

		var lH = lineBar.offsetHeight;
		var bH = bar.offsetHeight;
		var bT = bar.offsetTop;
		var tH = text.offsetHeight;

		bar.onmousedown = function (ev) {
			var ev = ev || window.event;
			var y = ev.clientY + window.pageYOffset;
			var oY = y - bT;
			document.onmousemove = function (ev) {
				var ev = ev || window.event;
				var target = ev.clientY + window.pageYOffset - y;
				if (target < 0) {
					target = 0;
				}
				if (target > lH - bH) {
					target = lH - bH;
				}
				bar.style.top = target + 'px';
				text.style.height = target / (lH - bH) * lH -2 + 'px';
			}
			document.onmouseup = function () {
				document.onmousemove = document.onmouseup = null;
			}
		}
	</script>
</body>
</html>